<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common_head(title)">
    <meta charset="UTF-8">
    <title th:text="${title}"></title>
    <link rel="stylesheet" th:href="@{/webjars/layui/2.5.7/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/front/common.css}">
    <script th:src="@{/webjars/layui/2.5.7/layui.js}"></script>
    <script th:src="@{/webjars/vue/2.6.12/vue.min.js}"></script>
    <script th:src="@{/webjars/vue-resource/0.9.3/vue-resource.min.js}"></script>
    <!-- 公共依赖的js模块 -->
    <script>
        //退出功能的用法
        function logout(){
            layui.use('layer', function(){
                //获取layer对象
                let layer = layui.layer;
                //获取jQuery对象
                let $ = layui.$;
                //弹出退出登录的提示
                layer.msg("亲，忍心离开我们吗？",{
                    time: 20000, //20秒后自动退出
                    btn: ['心意已决', '取消退出'],
                    btnAlign: 'c',
                    yes: () => {
                        $.ajax({
                            url: '/user/logout',
                            method: 'post',
                            success: function (res){
                                if (res == 1){

                                    window.location.href = "/page/frontIndex";
                                }
                            }
                        })
                    },
                    btn2: () => {
                        layer.msg("亲，您的选择是正确的",{
                            time: 1000
                        })
                    }
                })
            });
        }
    </script>
</head>
<body>
    <!-- 公共的头部介绍 -->
    <header th:fragment="common_header(activeUri,nav_name)" >
        <ul class="layui-nav" >
            <li class="layui-nav-item">
                <a href="javascript:;">[[${nav_name}]]</a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/page/frontIndex}" style="color: #1E9FFF">首页</a>
            </li>
            <li class="layui-nav-item" th:if="${session.get('user') == null}">
                <a th:href="@{/page/loginSelect}" style="color: #1E9FFF">登录</a>
            </li>
            <li class="layui-nav-item" th:if="${session.get('user') != null}">
                <a th:href="@{/page/learnerInformation}"style="color: #1E9FFF">我的信息</a>
            </li>
            <li class="layui-nav-item" th:if="${session.get('user') == null}">
                <a th:href="@{/page/registerSelect}"style="color: #1E9FFF">注册</a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/page/backLogin}"style="color: #1E9FFF">网站后台管理</a>
            </li>
            <li class="layui-nav-item">
                <a  th:if="${session.get('user') == null}">尊敬的用户，您还未登录我们的网站！</a>
                <a  th:if="${session.get('user') != null}">尊敬的[[${session.user.userName}]],欢迎您的光临！</a>
            </li>
            <li class="layui-nav-item" th:if="${session.get('user') != null} " >
                <a th:href="@{/page/learnerUpdate}"style="color: #1E9FFF">修改密码</a>
            </li>

            <li class="layui-nav-item" th:if="${session.get('user') != null}">
                <button type="button" class="layui-btn layui-btn-danger" onclick="logout()">退出网站</button>
            </li>

        </ul>
    </header>
    <!-- 底部公司信息介绍 -->
    <footer th:fragment="footer-common">
        <div class="container-fluid footer-common">
            <div class="row">
                <div class="col-xs-6 col-md-6 footer-common-text">
                    有问题联系管理员
                </div>
                <div class="col-xs-6 col-md-6 footer-common-text">
                    <img th:src="@{/image/front/WeChatWen.jpg}" width="100" alt="二维码">
                </div>
                <div class="col-xs-6 col-md-6 footer-common-text">
                    作者：温家豪
                </div>
            </div>
        </div>
    </footer>
    <!-- 公共的顶部导航部分 -- 网站的 后台部分 -->
    <header th:fragment="common_header_back(activeUri,nav_name)">
        <ul class="layui-nav" style="border-radius: unset;text-align: right;">
            <li class="layui-nav-item" style="float: left">
                <a th:text="${nav_name}" href="#" style="font-size: 24px;"></a>
            </li>
            <li class="layui-nav-item">
                <a th:href="@{/page/frontIndex}">前台首页</a>
            </li>
            <li class="layui-nav-item">
                <a href=""><img th:src="@{/image/front/jiaolian.png}" class="layui-nav-img">[[${session.user.userName}]]</a>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:logout();">退出登录</a>
            </li>
        </ul>
    </header>
    <!-- 侧边导航部分 左边 -->
    <nav th:fragment="common_left_nav(activeUri,nav_name)">
        <ul class="layui-nav layui-nav-tree" style="border-radius: unset;height: 800px" lay-filter="test">
            <li class="layui-nav-item">
                <a href="javascript:;">题库管理</a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/page/backSeeAllQuestion}">全部试题</a></dd>
                    <dd><a th:href="@{/page/importQuestion}">批量导入题库</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;">考试管理</a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/page/testManage}">时间及分数设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" th:if="${session.user.userId==1}">
                <a href="javascript:;">审批管理</a>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/page/toApproveUser}">管理员审批</a></dd>
                </dl>
                <dl class="layui-nav-child">
                    <dd><a th:href="@{/page/toCancelApprove}">取消管理员权限</a></dd>
                </dl>
            </li>
        </ul>
    </nav>
</body>
</html>
